/*******************************************************************************
 * Copyright 2011 @ Kapil Viren Ahuja
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 ******************************************************************************/
package com.kapilvirenahuja.eamsteps.form;

import java.util.Map;

import com.kapilvirenahuja.eamsteps.dataprovider.AbstractDataProvider;
import com.kapilvirenahuja.eamsteps.dataprovider.IDataProvider;
import com.kapilvirenahuja.eamsteps.datareader.IDataSet;
import com.kapilvirenahuja.eamsteps.datareader.IDataTable;

/**
 * <p>
 * This interface is used by the {@link IDataProvider} as the target area where the data is to be stored. A
 * {@link IDataForm} has a relationship with the underlying data source. The {@link IDataForm} should have a list of
 * getters and setters for every {@link IDataTable} that is stored in the {@link IDataSet}. If any of the getters or
 * setters are missing the initialization will halt - refer to {@link AbstractDataProvider#validateForm()} for more
 * details.
 * </p>
 * 
 * 
 * @author Kapil Viren Ahuja
 * 
 */
public interface IDataForm
{
    /**
     * This method will be responsible for adding the data passed to the form. The implementations should add the
     * <code>object</code> to the respective <code>dataTable</code> with <code>index</code> to an underlying datastore.
     * <code>Index</code> will be used as the key to row in the <code>dataTable</code>.
     * 
     * @param dataTableName
     * @param index
     * @param object
     */
    void addData(String dataTableName, String index, Object object);


    /**
     * This method will be responsible for fetching the data from the form. The implementations should read the data
     * from the underlying {@link Map} based on the <code>key</code> represented by the dataTable name.
     * 
     * @param dataTableName - name of the table from which the data is to be read
     * @param index - row index
     */
    Object getData(String dataTableName, Integer index);


    /**
     * This method will be responsible for response data passed to the form. The implementations should add the
     * <code>object</code> to the respective <code>dataTable</code> with <code>index</code> to an underlying datastore.
     * <code>Index</code> will be used as the key to row in the <code>dataTable</code>.
     * 
     * @param dataTableName
     * @param index
     * @param object
     */
    void addResponse(String dataTableName, String index, Object object);


    /**
     * This method will be responsible for fetching the response data from the form. The implementations should read the
     * data from the underlying {@link Map} based on the <code>key</code> represented by the dataTable name.
     * 
     * @param dataTableName - name of the table from which the data is to be read
     * @param index - row index
     */
    Object getResponse(String dataTableName, Integer index);


    /**
     * This method returns the corresponding Class name for a data table.
     * 
     * @param dataTableName
     * @return
     */
    String getObjectType(String dataTableName);
}
